(function () {
    let aInputs = document.querySelectorAll("input");
    //前端和后端交互
    //network
    aInputs[2].addEventListener("click", function () {
      let data = {
        username: aInputs[0].value,
        password: aInputs[1].value,
      };
      AP("/users/login", data).then((resData) => {
        console.log(resData.data);
        if (resData.data.code == 1) {
          localStorage.setItem("token", resData.data.token);
          localStorage.setItem("uid", resData.data.user.id);
  
          if (location.search.includes("returnUrl")) {
            //history.back();
            location.href = location.search.substring(11);
          } else {
            location.href = "index.html";
          }
        } else {
          alert("登录失败");
        }
      });
    });
  })();